package com.xiaomaoguai.dianping.htmlBean;

import java.util.List;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.HtmlField;
import com.geccocrawler.gecco.annotation.Request;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.spider.HtmlBean;

@Gecco(matchUrl = "http://t.dianping.com/list/shenzhen-category_30", pipelines = { "consolePipeline",
		"shopIndexDataPipeline" })
public class CategoryListBean implements HtmlBean {

	private static final long serialVersionUID = 1L;

	@Request
	private HttpRequest request;

	@HtmlField(cssPath = "ul.tg-floor-list>.tg-floor-item")
	private List<ShopIndex> shops;

	public List<ShopIndex> getShops() {
		return shops;
	}

	public void setShops(List<ShopIndex> shops) {
		this.shops = shops;
	}

	public CategoryListBean() {
		super();
	}

	public HttpRequest getRequest() {
		return request;
	}

	public void setRequest(HttpRequest request) {
		this.request = request;
	}

	public static void main(String[] args) {
		HttpGetRequest start = new HttpGetRequest("http://t.dianping.com/list/shenzhen-category_30");
		start.addCookie("_hc.v", "c0cb142c-e377-4248-956c-5b69c9da43bf.1487316489; aburl=1; PHOENIX_ID=0a017912-15a59355e54-24870c4f; __mta=44806811.1487316490667.1487316539015.1487555377549.3; _tr.u=pwyrNRYXBuOBPlh4; tg_list_scroll=0; JSESSIONID=F6F53AEA729CF3C7701C7DD8E1CC1DEC; cy=7; cye=shenzhen; _tr.s=DMFR5s2hJXcpyCB8");
		start.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
		start.addHeader("Accept-Encoding", "gzip, deflate, sdch");
		start.addHeader("Accept-Language", "zh-CN,zh;q=0.8");
		start.addHeader("Cache-Control", "max-age=0");
		start.addHeader("Connection", "keep-alive");
		start.addHeader("Host", "t.dianping.com");
		start.addHeader("Referer", "http://t.dianping.com/list/shenzhen-category_20");
		start.addHeader("Upgrade-Insecure-Requests", "1");
		start.addHeader("User-Agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36");
		start.setCharset("GBK");
		GeccoEngine.create().classpath("com.xiaomaoguai.dianping.htmlBean").interval(2000).start(start).run();
	}
}
